<template>
	<view class="coupon-index">
		<view class="card" v-for="(item, index) in couponlist" :key="index" @tap.stop="goto">
		
			<view class="card-left">
		
				<view class="pt_left">
					<view class="pt_left-content">
						<view class="f1" v-if="item.type == 1"><text class="t0">￥</text><text class="t1">{{
						item.money }}</text></view>
						<view class="f1" v-if="item.type == 41"><text class="t0">￥</text><text class="t1">{{
						item.money }}</text></view>
						<view class="f1" v-if="item.type == 30"><text class="t0">￥</text><text class="t1">{{
						item.money }}</text></view>
						<view class="f1" v-if="item.type == 10"><text class="t1">{{ item.discount / 10
					}}</text><text class="t0">折</text></view>
						<view class="f1" v-if="item.type == 2">礼品券</view>
						<view class="f1" v-if="item.type == 3"><text class="t1">{{ item.limit_count
					}}</text><text class="t2">次</text></view>
						<view class="f1" v-if="item.type == 4">抵运费</view>
						<view class="f1" v-if="item.type == 5"><text class="t0">￥</text><text class="t1">{{
						item.money }}</text></view>
						<view class="f1" v-if="item.type == 40">电影通用兑换券</view>
						<view class="f1" v-if="item.type == 20">券包</view>
					</view>
				</view>
			</view>
			<view class="card-item">
				<view class="card-right">
					<view class="card-time fw-700">
						{{ item.name }}
					</view>
					<view class="card-time">
						<text class="t2" v-if="item.type == 1">商品券</text>
						<text class="t2" v-if="item.type == 41">新人券</text>
						<text class="t2" v-if="item.type == 30">当面付抵扣券</text>
						<text class="t2" v-if="item.type == 2">礼品券</text>
						<text class="t2" v-if="item.type == 3">计次券</text>
						<text class="t2" v-if="item.type == 4">运费抵扣券</text>
						<text class="t2" v-if="item.type == 20">券包</text>
						<text class="t2" v-if="item.type == 40">电影通用兑换券</text>
						<view class="">
							<text class="t2"
								v-if="!item.from_mid && (item.isgive == 1 || item.isgive == 2)">可赠送</text>
						</view>
		
						<view class="t4" v-if="item.bid > 0">适用商家：{{ item.bname }}</view>
					</view>
					<view class="card-time">有效期至 {{ item.endtime }}</view>
				</view>
		
			</view>
			
		</view>
		<view class="no-data-tip" v-if="noMore && !loading">
		      <text>没有更多数据了</text>
		    </view>
	</view>
</template>

<script>
	var app = getApp()
	export default {
		data() {
			return {
				couponlist: [],
				shareData: {},
				opt: {},
				 noMore: false 
			}
		},
		onLoad(opt) {
			this.opt = app.getopts(opt);
			this.getlist();
		},


		methods: {
			getlist() {
			  if (this.loading) return;
			  
			  this.loading = true;
			  let that = this;
			
			  uni.showLoading({ title: '加载中' });
			
			  app.get('Coupon/getCouponActiveDetial', {
			    coupon_active_id: that.opt.coupon_active_id
			  }, function(res) {
			    uni.hideLoading();
			    that.loading = false;
			
			    if (res.code == 200) {
			      that.couponlist = res.data.couponlist || [];
			      // 判断是否没有数据
			      that.noMore = that.couponlist.length === 0;
			    } else {
			      uni.showToast({ title: res.msg || '加载失败', icon: 'none' });
			    }
			  }, function(err) {
			    uni.hideLoading();
			    that.loading = false;
			    uni.showToast({ title: '网络错误', icon: 'none' });
			  });
			},
			handleView(item) {
				// 查看活动逻辑
				console.log('查看活动', item)
			},

			// 下拉刷新
			onPullDownRefresh() {
				this.page = 1
				this.noMore = false
				this.getlist()
				setTimeout(() => {
					uni.stopPullDownRefresh()
				}, 1000)
			}
		}
	}
</script>

<style scoped>
	.coupon-index {
		padding: 20rpx;
		background-color: #fff;
		height: 100vh;
	}

	.coupon-list {
		padding: 20rpx;
		border-radius: 10rpx;
		background-color: rgba(255, 255, 255, 1);
		box-shadow: 0px 4rpx 12rpx 0px rgba(0, 0, 0, 0.4);
		border: 1px solid rgba(187, 187, 187, 1);
		margin-bottom: 40rpx;
		display: flex;
	}

	.coupon-list-left {
		margin-right: 50rpx;
		position: relative;
		width: 200rpx;
		height: 200rpx;
	}

	.coupon-list-left-img {
		width: 100%;
		height: 100%;
	}

	.money-overlay {
		position: absolute;
		bottom: 20rpx;
		left: 0;
		right: 0;
		text-align: center;
		color: rgba(16, 16, 16, 1);
		font-size: 36rpx;
		font-weight: bold;

	}

	.coupon-list-right {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		flex: 1;
	}

	.coupon-list-right-title {
		color: rgba(16, 16, 16, 1);
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.coupon-list-right-time {
		color: rgba(138, 138, 138, 1);
		font-size: 26rpx;
	}

	.coupon-list-right-btn {
		display: flex;
		justify-content: flex-end;
		gap: 20rpx;
	}

	.right-btn {
		border: 1px solid rgba(187, 187, 187, 1);
		color: rgba(16, 16, 16, 1);
		font-size: 28rpx;
		width: 160rpx;
		height: 54rpx;
		text-align: center;
		line-height: 54rpx;
		border-radius: 56rpx;
		margin: unset;
	}

	.load-more {
		text-align: center;
		padding: 20rpx;
		font-size: 24rpx;
		color: #999;
	}
	.card {
		display: flex;
		align-items: center;
		width: 100%;
		background-color: #AD62D7;
	
		border-radius: 8px;
		-webkit-mask-image: radial-gradient(circle at 88px 4px, transparent 4px, red 4.5px), radial-gradient(closest-side circle at 50%, red 99%, transparent 100%);
		/* -webkit-mask-size: 100%, 2px 4px; */
		-webkit-mask-repeat: repeat, repeat-y;
		-webkit-mask-position: 0 -8rpx, 168rpx;
	
		position: relative;
		margin-bottom: 20rpx;
	}
	
	.card-left {
		width: 88px;
		text-align: center;
		font-size: 18px;
		color: #fff;
	
	}
	
	.card-left-top {
		position: absolute;
		top: 0;
		left: 0;
		font-size: 24rpx;
		padding: 4rpx 12rpx;
		border-bottom-right-radius: 30rpx;
	}
	
	.card-right {
		padding: 16px 12px;
		display: flex;
	
		flex-direction: column;
	}
	
	.card-info {
		margin: 0;
		font-size: 14px;
		line-height: 20px;
		color: #fff;
	}
	
	.card-time {
		font-size: 12px;
		line-height: 16px;
		font-weight: normal;
		color: #fff;
		margin-top: 4px;
	}
	
	.card-right-text {
		display: flex;
		align-items: center;
		color: #fff;
	}
	
	.card-right-img {
		width: 30rpx;
		height: 30rpx;
	}
	
	.card-left-money {
		font-size: 24rpx
	}
	
	.card-btn-box {}
	
	.card-btn {
		color: #fff;
		border-radius: 30rpx;
		padding: 10rpx 30rpx;
		font-size: 24rpx;
		text-align: center;
	}
	
	.card-btn-text {
		font-size: 24rpx;
		color: #fff;
	}
	
	.card-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex: 1;
		padding: 0 20rpx 0 0;
	}
	
	.card-item::before {
		content: '';
		position: absolute;
	
		top: 0;
		bottom: 0;
		width: 2px;
		border-left: 1px dashed #fff;
	
	}
	.no-data-tip {
	  text-align: center;
	  padding: 40rpx;
	  font-size: 28rpx;
	  color: #999;
	  background: #f8f8f8;
	  border-radius: 10rpx;
	  margin: 20rpx 0;
	}
</style>